﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace VSM
{
    public partial class Main : System.Web.UI.MasterPage
    {
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[Utils.AppConstants.ID_User] == null
                || Session[Utils.AppConstants.Password] == null
                || Session[Utils.AppConstants.ID_Dealer] == null)
            {
                Response.Redirect("Login.aspx");
            }
            if (!IsPostBack)
            {
                //if (Session[Utils.AppConstants.U_Department].ToString().CompareTo(Utils.AppConstants.PARTS) == 0)
                //{
                //    mnAdmin.Visible = 
                //    mnVehicle.Visible = false;
                //    mnDataCenter.Visible = 
                //    mnPart.Visible = true;
                //}
                //else if(Session[Utils.AppConstants.U_Department].ToString().CompareTo(Utils.AppConstants.SALES) == 0)
                //{
                //    mnAdmin.Visible = 
                //    mnPart.Visible = false;
                //    mnDataCenter.Visible = 
                //    mnVehicle.Visible = true;
                //}
                //else if (Session[Utils.AppConstants.U_Department].ToString().CompareTo(Utils.AppConstants.ICT) == 0)
                //{
                //    mnPart.Visible =
                //    mnDataCenter.Visible =
                //    mnVehicle.Visible = false;
                //    mnAdmin.Visible = true;
                //}
            }
            //this.lnkBack.Attributes.Add("onClick", "javascript:history.back(); return false;");
            /*if (Session[Utils.AppConstants.UserCode] != null
                && Session[Utils.AppConstants.CompanyName] != null
                && Session[Utils.AppConstants.CompanyCode] != null
                 && Session[Utils.AppConstants.OutletCode] != null
                   && Session[Utils.AppConstants.OutletName] != null
                  && Session[Utils.AppConstants.IsSupperUser] != null
                 && Session[Utils.AppConstants.Pwd] != null)
            {
                //this.lblUser.Text = Session[Utils.AppConstants.UserCode].ToString().ToUpper();
                if (Session[Utils.AppConstants.IsSupperUser].ToString() == "N")
                {
                    //this.lblOutlet.Text = Session[Utils.AppConstants.CompanyName].ToString() + ", Outlet: " + Session[Utils.AppConstants.OutletName].ToString();
                }
                else
                {
                    //this.lblOutlet.Text = Session[Utils.AppConstants.CompanyName].ToString();
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }*/
        }
        /// <summary>
        /// Logout Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lnkLogout_Click(object sender, EventArgs e)
        {
            try
            {
                /*GetDefault obj = new GetDefault();
                obj.LogOut();
                Session.Abandon();*/
                Response.Redirect("Login.aspx");
            }
            catch (Exception ex)
            {

            }
        }
        /// <summary>
        /// Home
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lnkHome_Click(object sender, EventArgs e)
        {
            Response.Redirect("Homepage.aspx");
        }

        protected void lnkBack_Click(object sender, EventArgs e)
        {
        }

        protected void LoginStatus1_LoggedOut(object sender, EventArgs e)
        {
            /*GetDefault obj = new GetDefault();
            obj.LogOut();
            Session.Abandon();*/
            Session[Utils.AppConstants.ID_User] = null;
            Session[Utils.AppConstants.Password] = null;
            Session[Utils.AppConstants.ID_Dealer] = null;
            Response.Redirect("~/Login.aspx");
        }
    }
}